Skip to content

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Oct 28, 2025

closes #9713

Solid query on the server hangs forever, because it always needs experimental_prefetchInRender:true on the server, but that's off by default. Since it always have to be on on the server, this PR detects isServer and set it true. It's because createResource uses promises.

Summary by CodeRabbit

  • Enhancements
    • Enabled experimental "prefetch in render" by default during server-side rendering to fetch data earlier in the render cycle — improving data availability, reducing SSR wait times, and producing more consistent initial renders for SSR pages.
    • Released a patch that rolls out this SSR prefetch behavior change.

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: b84bbeb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tanstack/solid-query Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query-persist-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Enables SSR prefetch during render in Solid Query by setting experimental_prefetchInRender = true on server-side default options inside useBaseQuery, changing SSR fetch timing to run during render (to support createResource) instead of waiting for effects.

Changes

Cohort / File(s) Change Summary
SSR Prefetch Configuration
packages/solid-query/src/useBaseQuery.ts
On the server execution path, sets defaultOptions.experimental_prefetchInRender = true and adds comments explaining the change; alters SSR behavior so queries prefetch during render to support createResource rather than waiting for effects.
Release metadata
.changeset/thirty-poems-yell.md
Adds a changeset marking a patch release that documents enabling experimental_prefetchInRender on server render.

Sequence Diagram(s)

sequenceDiagram
  participant Server
  participant useBaseQuery
  participant QueryClient
  participant createResource

  rect rgb(240,248,255)
    Server->>useBaseQuery: render() (server path)
    useBaseQuery->>QueryClient: set defaultOptions.experimental_prefetchInRender = true
    useBaseQuery->>QueryClient: prefetch query during render (sync-ish)
    QueryClient-->>useBaseQuery: returns promise/observable
    useBaseQuery->>createResource: provide data/promise to createResource during render
    createResource-->>Server: suspends/resolves for SSR output
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect useBaseQuery server-only branching to confirm the flag is applied only on server paths.
  • Validate comments and option mutation don't leak into client defaults.
  • Review SSR test coverage and any integrations relying on prior effects-based fetch timing (e.g., Astro integration).
  • Check .changeset metadata for correct release tagging.

Possibly related PRs

Poem

🐰 In server-render burrows I hop with delight,

prefetchInRender< now turns on the light,
createResource wakes while I softly nibble code,
SSR no longer waits on effects' slow road,
Hooray — fast renders, carrot-shaped and bright! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description provides a brief explanation of the problem and solution but does not follow the required template structure. The template specifies three main sections: "🎯 Changes" with motivation, "✅ Checklist" with verification steps, and "🚀 Release Impact" declaring whether the change affects published code. The actual description lacks all these structured sections, the checklist items, and does not explicitly declare that a changeset was generated (though one was included). While the descriptive content is relevant and explains the technical issue adequately, the complete absence of the required template format and checklist items constitutes a failure to meet the repository's contribution standards. The PR description should be updated to follow the template format. Add the "🎯 Changes" section with the detailed explanation of changes and motivation, include the "✅ Checklist" with checkboxes confirming the contributing guide was followed and tests were run (mark as completed if already done), and add the "🚀 Release Impact" section to document that this change affects published code and that a changeset was generated. This ensures consistency with repository standards and allows reviewers to quickly verify that proper development practices were followed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix(solid-query): enable experimental_prefetchInRender by default for…" clearly summarizes the main change in the PR. It specifies the package being fixed (solid-query), the type of change (fix), and the primary objective (enabling experimental_prefetchInRender by default). The title accurately reflects the code modifications to useBaseQuery.ts and the corresponding changeset, making it easy for reviewers scanning history to understand the change at a glance.
Linked Issues Check ✅ Passed The code changes directly address the requirements specified in linked issue #9713. The modification to useBaseQuery.ts implements the non-breaking solution requested by enabling experimental_prefetchInRender on the server path when isServer is detected. This approach automatically enables the required behavior during server rendering without requiring manual configuration, which resolves the SSR hang issue caused by Solid Query's createResource using promises. The addition of the changeset properly documents the release impact, and the implementation matches the workaround (setting experimental_prefetchInRender: true) that was confirmed to fix the problem in the issue.
Out of Scope Changes Check ✅ Passed All changes in the pull request are directly related to the stated objective of enabling experimental_prefetchInRender by default during server rendering. The modification to packages/solid-query/src/useBaseQuery.ts implements the core requirement by detecting the server environment and setting experimental_prefetchInRender to true, which addresses the SSR hang in issue #9713. The addition of .changeset/thirty-poems-yell.md properly documents the release impact as a patch version bump for @tanstack/solid-query. No extraneous or unrelated changes are present in this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enable-experimental_prefetchInRender-by-default-for-solid

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bedefb6 and b84bbeb.

📒 Files selected for processing (1)
  • .changeset/thirty-poems-yell.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/thirty-poems-yell.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Oct 28, 2025

View your CI Pipeline Execution ↗ for commit b84bbeb

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 56s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-01 14:35:08 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 28, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9822

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9822

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9822

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9822

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9822

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9822

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9822

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9822

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9822

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9822

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9822

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9822

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9822

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9822

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9822

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9822

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9822

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9822

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9822

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9822

commit: b84bbeb

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

Sizes for commit b84bbeb:

Branch Bundle Size
Main
This PR

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.39%. Comparing base (38b4008) to head (b84bbeb).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9822       +/-   ##
===========================================
+ Coverage   45.74%   76.39%   +30.65%     
===========================================
  Files         200       19      -181     
  Lines        8404      394     -8010     
  Branches     1919       81     -1838     
===========================================
- Hits         3844      301     -3543     
+ Misses       4112       76     -4036     
+ Partials      448       17      -431     
Components Coverage Δ
@tanstack/angular-query-experimental ∅ <ø> (∅)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools ∅ <ø> (∅)
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query ∅ <ø> (∅)
@tanstack/react-query-devtools ∅ <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client ∅ <ø> (∅)
@tanstack/solid-query 77.81% <0.00%> (-0.26%) ⬇️
@tanstack/solid-query-devtools 61.90% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Enable experimental_prefetchInRender by default for @tanstack/solid-query.
@TkDodo TkDodo merged commit 6ebee2e into main Nov 1, 2025
8 of 9 checks passed
@TkDodo TkDodo deleted the enable-experimental_prefetchInRender-by-default-for-solid branch November 1, 2025 14:36
@github-actions github-actions bot mentioned this pull request Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Solid Query breaks Astro SSR

3 participants